<template>
    <div class="filtrate-resume">
        <div>
            <el-select v-model="jobIdsel" style="width: 300px" class="filtrate-select" @change="selChange">
                <el-option
                        v-for="item in options"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                </el-option>
            </el-select>
        </div>
        <div class="filtrate-resume-right">
      <span class="recommend-text platform" v-if="showlable == 1">
        <img src="../../assets/img/resume/pingtai.png">平台推荐数&nbsp; {{onlResRecommendNums}}
      </span>
            <span class="recommend-text oneself" v-if="showlable == 0">
        <img src="../../assets/img/resume/zijian.png">自荐数&nbsp; {{onlineResumeNums}}
      </span>
            <!--<span class="refresh-button" @click="doRefresh">-->
        <!--<img src="../../assets/img/resume/shuaxin.png">刷新-->
      <!--</span>-->
        </div>
    </div>
</template>

<script>
  import * as _ from 'underscore'

  export default {
    props: {
      jobList: {
        type: Array,
        default() {
          return []
        }
      }
    },
    data() {
      return {
        showlable: 1,
        onlResRecommendNums: 0,
        onlineResumeNums: 0,
        jobId: 0,
        options: [],
        jobIdsel: 0
      }
    },
    methods: {
      doRefresh() {
        console.log('刷新职位的简历列表')
        this.init()
      },
      init() {
        console.log('job list total', this.jobList)
        this.jobIdsel = parseInt(localStorage.getItem('job_List_jobId'))//职位ID
        this.showlable = localStorage.getItem('job_List_type')//推荐状态
        this.onlResRecommendNums = localStorage.getItem('job_List_onlResRecommendNums')//平台推荐数
        this.onlineResumeNums = localStorage.getItem('job_List_onlineResumeNums')//自荐数
        let items = JSON.parse(localStorage.getItem('job_List_data'))//总对象
        //封装下拉列表显示数据
        this.options.splice(0, this.options.length)
        for (let i = 0; i < items.length; i++) {
          let item = items[i]
          this.options.push({
            value: item.id,
            label: (item.name + ' | ' + item.city + ' | ' + (Number(item.tax) === 0 ? '税前' : '税后') + (item.salaryPerMonthLow + '-' + item.salaryPerMonthHigh) + ' W/ ' + item.salaryCount + ' 年')
          })
        }
      },
      selChange(vId) {
        let current = _.find(this.jobList, o => o.id === vId)
        console.log('current job', current)
        if (current) {
          this.onlResRecommendNums = current.onlResRecommendNums
          this.onlineResumeNums = current.onlineResumeNums
        }
        this.$emit('getJobId', vId)
      }
    },
    components: {},
    created() {
      this.init()
    }
  }
</script>

<style lang="scss" scoped>
    .filtrate-resume {
        padding: 0 50px;
        width: 980px;
        height: 50px;
        background: #fff;
        border-top: 1px solid #f2f2f2;
        display: flex;
        justify-content: space-between;
        align-items: center;

        .filtrate-resume-right {
            display: flex;
            justify-content: space-between;
            align-items: center;

            .recommend-text {
                font-size: 14px;
                color: #333;
                display: flex;
                align-items: center;

                img {
                    margin: 0 10px 0 0;
                }
            }
        }

        .refresh-button {
            margin: 0 0 0 46px;
            cursor: pointer;
            font-size: 18px;
            color: #333;
            display: flex;
            align-items: center;

            img {
                margin: 0 9px 0 0;
            }
        }
    }
</style>
